package com.itchen.hospital.controller;

import com.itchen.hospital.common.Result;
import com.itchen.hospital.pojo.Admin;
import com.itchen.hospital.service.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
@Tag(name = "登录接口")
@CrossOrigin
@RequiredArgsConstructor
public class LoginController {

    private final LoginService loginService;

    @PostMapping
    @Operation(summary = "登录")
    public Result login(Admin admin) {
        Admin login = loginService.login(admin);
        return Result.success(login);
    }

    @PostMapping("/register")
    @Operation(summary = "注册")
    public Result register(Admin admin) {
        return loginService.register(admin);
    }

}
